<span class="glyphicon glyphicon-map-marker" aria-hidden="true" style="position: absolute; top: 27px; left: 45px;">
    <span>系统</span> /
    <span>banner轮滚</span> /
    <span>编辑banner轮滚图</span>
</span>
<row>
    <div class="col-md-8 col-md-offset-2"  style="margin-top: 37px;margin-left: 5px;">
        <form class="form-horizontal" id="form">
            <div class="form-group">
                <label for="name" class="col-md-3 control-label">
                    <div class="text-center">banner标题</div>
                </label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="name"
                           name="name" value="{$banner.name}" placeholder="banner标题">
                </div>
            </div>
            <div class="form-group">
                <label for="logo" class="col-md-3 control-label">
                    <div class="text-center">banner首页</div>
                </label>
                <div class="col-md-9">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test1" style="background-color: #5bb75b;">上传图片</button>
                        <span style="color: #aaaaaa;">建议像素：625px*325px</span>
                        <input type="hidden" id="logo" name="logo" value="{$banner.logo}" />
                        <br /><br />
                        <div class="gs_cont_img" style="width: 150px; height: auto;">
                            {if condition="$banner.UploadLogo"}
                            <img src="__IMG__/{$banner.UploadLogo.path}" id="image" width="100%" />
                            {else /}
                            <img src="__IMG__/1.png" id="image" width="100%" />
                            {/if}
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label for="sort" class="col-md-3 control-label">
                    <div class="text-center">排序顺序</div>
                </label>
                <div class="col-md-9">
                    <input type="number" class="form-control" id="sort" name="sort"
                           step="1" min="0" value="{$banner.sort}"  placeholder="排序顺序">
                </div>
            </div>
            <div class="form-group save-btn" style="">
                <a href="javascript:edit({$banner.id})" class="ncap-btn-big ncap-btn-green"
                   style="background-color: #00a0e9;">提交</a>
                <a href="{:url('admin/Banner/index')}" class="ncap-btn-big ncap-btn-green"
                   style="background-color: #ff0055;">返回</a>
            </div>
        </form>
    </div>
</row>
<script type="text/javascript">
    function edit(id) {
        var titles = $("#name").val();
        var logo = $("#logo").val();
        if(titles == ""){
            return title("请输入banner标题");
        }
        if (logo == 0){
            return title("请输入banner图片");
        }
        var sort = $("#sort").val();
        if(sort <= -1){
            sort = id;
        }
        var json = {id:id,sort:sort,name:titles,logo:logo};
        $.ajax({
            type:"post",
            url:"{:url('admin/Banner/add')}",
            data:json,
            success:function (res) {
                title(res);
                if(res == "更新成功" ) {
                    setTimeout("Banner()",1500);
                    return;
                }
                setTimeout("location_href()",1500);
            }
        });
    }
    function Banner() {
        window.location.href = "{:url('admin/Banner/index')}";
    }
</script>
